home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 26 / Cream of the Crop 26.iso / program / wdj0697.zip / TECHTIPS.ZIP / TIPSVIEW.CPP < prev    next >
C/C++ Source or Header  |  1996-06-23  |  2KB  |  111 lines

  1. // TipsView.cpp : implementation of the CTipsView class
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include "Tips.h"
  6.  
  7. #include "TipsDoc.h"
  8. #include "TipsView.h"
  9.  
  10. #ifdef _DEBUG
  11. #define new DEBUG_NEW
  12. #undef THIS_FILE
  13. static char THIS_FILE[] = __FILE__;
  14. #endif
  15.  
  16. /////////////////////////////////////////////////////////////////////////////
  17. // CTipsView
  18.  
  19. IMPLEMENT_DYNCREATE(CTipsView, CView)
  20.  
  21. BEGIN_MESSAGE_MAP(CTipsView, CView)
  22.     //{{AFX_MSG_MAP(CTipsView)
  23.     ON_WM_CREATE()
  24.     //}}AFX_MSG_MAP
  25. END_MESSAGE_MAP()
  26.  
  27. /////////////////////////////////////////////////////////////////////////////
  28. // CTipsView construction/destruction
  29.  
  30. CTipsView::CTipsView()
  31. {
  32.     // TODO: add construction code here
  33.  
  34. }
  35.  
  36. CTipsView::~CTipsView()
  37. {
  38. }
  39.  
  40. BOOL CTipsView::PreCreateWindow(CREATESTRUCT& cs)
  41. {
  42.     // TODO: Modify the Window class or styles here by modifying
  43.     //  the CREATESTRUCT cs
  44.  
  45.     return CView::PreCreateWindow(cs);
  46. }
  47.  
  48. /////////////////////////////////////////////////////////////////////////////
  49. // CTipsView drawing
  50.  
  51. void CTipsView::OnDraw(CDC* pDC)
  52. {
  53.     CTipsDoc* pDoc = GetDocument();
  54.     ASSERT_VALID(pDoc);
  55.  
  56.     // TODO: add draw code for native data here
  57. }
  58.  
  59. /////////////////////////////////////////////////////////////////////////////
  60. // CTipsView diagnostics
  61.  
  62. #ifdef _DEBUG
  63. void CTipsView::AssertValid() const
  64. {
  65.     CView::AssertValid();
  66. }
  67.  
  68. void CTipsView::Dump(CDumpContext& dc) const
  69. {
  70.     CView::Dump(dc);
  71. }
  72.  
  73. CTipsDoc* CTipsView::GetDocument() // non-debug version is inline
  74. {
  75.     ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CTipsDoc)));
  76.     return (CTipsDoc*)m_pDocument;
  77. }
  78. #endif //_DEBUG
  79.  
  80. /////////////////////////////////////////////////////////////////////////////
  81. // CTipsView message handlers
  82.  
  83. int CTipsView::OnCreate(LPCREATESTRUCT lpCreateStruct) 
  84. {
  85.     if (CView::OnCreate(lpCreateStruct) == -1)
  86.         return -1;
  87.     
  88.     EnableToolTips () ;    
  89.     return 0;
  90. }
  91.  
  92.  
  93. int 
  94. CTipsView::OnToolHitTest(CPoint point, TOOLINFO* pTI) const
  95. {
  96.     const int nID = MAKELONG (point.x, point.y) + 1 ;
  97.  
  98.     if (pTI != NULL)
  99.     {
  100.         pTI->hwnd = m_hWnd;
  101.         pTI->uId = nID ;
  102.         pTI->rect = CRect (point, CSize (1, 1)) ;
  103.  
  104.         CString str ;
  105.         str.Format ("%ld, %ld", point.x, point.y) ;
  106.         // warning! MFC deletes this string - one must pass a copy
  107.         pTI->lpszText = _strdup (str) ;
  108.     }
  109.     return nID ;
  110. }
  111.